<?php 

require_once 'i_global.php';
require_once 'func_act_edit.php';

redirectIfNotLoggedIn();

if($_REQUEST['submit'] != NULL) {
	$actID = saveActivity();
	if($actID > 0) {
		echo "SAVED successfully.";
	} else {
		echo "ERROR: " . $actID;
	}
} 

$activity_id = $_REQUEST['activity_id'];
if($activity_id > 0) {
	$act = getActivity($activity_id);
}

require_once 'p_header.php';
?>
<div class="span10">
            <ul class="tabs">
              <li class="active"><a href="#">Latest Activities</a></li>
              <li><a href="#">Popular Activities</a></li>
              <li><a href="#">Charity Activities</a></li>
            </ul>

<div class="span9">
        

<?php 
$acts = getActivities();
foreach ($acts as &$act) {
	
	$userAct = $_SESSION['user'] == NULL ? NULL : getUserAct($act['activity_id'], $_SESSION['user']['user_id']);
?>

<h3><a href='show_act.php?activity_id=<?php echo $act['activity_id']; ?>'><?php echo $act['title']; ?></a>
<?php 
if($userAct != NULL) {
	if($userAct['status'] == 'DONE') {
		echo '<span class="label notice">Completed!</span>';
	} else {
		echo '<span class="label success">Registered</span>';
	}	
}
?>
</h3>
<img src='<?php echo $act['picture']?>' height="80" align="right" style="margin-left: 12px;"/>
<?php echo $act['extract']?>

<?php 
}
?>
  
  
        
        
        
</div>
            <div class="span9">
            &nbsp; 
            </div>
            
            <div class="pagination " >
              <ul>
                <li class="prev disabled"><a href="#">&larr; Previous</a></li>
                <li class="active"><a href="#">1</a></li>
                <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">5</a></li>
                <li class="next"><a href="#">Next &rarr;</a></li>
              </ul>
            </div>


</div><!-- end div span9 -->
<?php 
require_once 'p_rightpanel.php';
require_once 'p_footer.php';

?>


